<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改客户信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-vo-edit" th:object="${vo}">
			<input id="custId" name="custId" type="hidden" th:field="*{custId}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">客户名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="custName" id="custName" th:field="*{custName}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">客户类型：</label>
				<div class="col-sm-8">
		            <input id='custTypePerson' th:checked="${vo.custType==0}" type="radio" th:field="*{custType}" value="0">
		            <label for="unStart" style="margin-bottom:5px;">个人</label>
		            <input id='custTypeCompany' th:checked="${vo.custType==1}" type="radio" th:field="*{custType}" value="1">
		            <label for="unStart" style="margin-bottom:5px;">单位</label>
					<!--
		            <input id='custTypePerson' th:checked="*{custType} eq '0'" type="radio" th:field="*{custType}" value="0">
		            <label for="unStart" style="margin-bottom:5px;">个人</label>
		            <input id='custTypeCompany' th:checked="*{custType} eq '1'" type="radio" th:field="*{custType}" value="1">
		            <label for="unStart" style="margin-bottom:5px;">单位</label>
		            -->
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">社会信用代码/身份号码：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="certNo" id="certNo" th:field="*{certNo}" required>
				</div>
			</div>
			
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "crm/custinfo";
		
		$("#form-vo-edit").validate({
			onkeyup: false,
			rules:{
				custName:{
					remote: {
		                url: ctx + "crm/custinfo/checkCertNoUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"custId": function() {
							    return $("input[name='custId']").val();
							},
		                	"custName" : function() {
		                        return $.common.trim($("#custName").val());
		                    },
		                	"certNo" : function() {
		                        return $.common.trim($("#certNo").val());
		                    }
		                }
		            }
				},
				sortNo:{
					digits:true
				},
			},
			messages: {
		        "custName": {
		            remote: "名称已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-vo-edit').serialize(), function() {
	        		$.modal.alertSuccess('保存成功！');
	        		$.modal.close();
        			});
	        }
	    }
	</script>
</body>
</html>
